<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历数组</title>
</head>

<body>
    <h1>JavaScript 数组</h1>
    <p>遍历数组的最佳方法是使用标准的 for 循环：</p>
    <p id="demo"></p>
    <script>
        var fruits, text, fLen, i;
        fruits = ["Banana", "Orange", "Apple", "Mango"];
        fLen = fruits.length;
        text = "<ul>";
        for (i = 0; i < fLen; i++) {
            text += "<li>" + fruits[i] + "</li>";
        }
        text += "</ul>";
        document.getElementById("demo").innerHTML = text;
    </script>
</body>

</html>